﻿using System.Data;
using Ue.Qcdz.Domain.ShopSinglePages;

namespace Ue.Qcdz.Repositories.ShopSinglePages
{
    public class ShopSinglePageDataQueryWhereClause : Ue.Infrastructure.RepositoryFramework.Repository.IWhereClause
    {

        private IShopSinglePageDataQuery shopSinglePageDataQuery;

        public ShopSinglePageDataQueryWhereClause(IShopSinglePageDataQuery dataQuery)
        {
            this.shopSinglePageDataQuery = dataQuery;
        }


        #region IWhereClause 成员

        public string Clause
        {

            get
            {
                string whereClause = "1=1";
                if (this.shopSinglePageDataQuery.Status)
                    whereClause += string.Format(" and {0} = 1", ShopSinglePageFactory.FieldNames.Status);
                if (!string.IsNullOrEmpty(this.shopSinglePageDataQuery.ShopId))
                    whereClause += string.Format(" and {0} = @{0}", ShopSinglePageFactory.FieldNames.ShopId);
                return whereClause;
            }

        }

        public System.Data.IDataParameter[] Parameters
        {
            get
            {
                return new IDataParameter[] {
                    SqlServerDriver.Instance.BuildParameter(ShopSinglePageFactory.FieldNames.ShopId,this.shopSinglePageDataQuery.ShopId)                
                };
            }
        }

        #endregion
    }
}
